package kr.saeildamil.androidstudy_second21;

import kr.saeildamil.androidstudy_second.R;
import android.content.Context;
import android.view.ActionProvider;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

public class CounterProvider extends ActionProvider {
	Context mContext;
	TextView mCountText;
	public CounterProvider(Context context) {
		super(context);
		this.mContext=context;
	}
	
	@Override
	@Deprecated
	public View onCreateActionView() {
		LayoutInflater inflater=LayoutInflater.from(mContext);
		View linear=inflater.inflate(R.layout.ch21_counterprovider, null);
		mCountText=(TextView) linear.findViewById(R.id.ch21_counterprovider_text);
		
		linear.findViewById(R.id.ch21_counterprovider_increase);
		linear.findViewById(R.id.ch21_counterprovider_decrease);
		return null;
	}
	OnClickListener listener=new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			int count=Integer.parseInt(mCountText.getText().toString());
			switch (v.getId()) {
			case R.id.ch21_counterprovider_increase:
				mCountText.setText(Integer.toString(count+1));
				break;
			case R.id.ch21_counterprovider_decrease:
				mCountText.setText(Integer.toString(count-1));
				break;
			}
		}
	};
	
	public boolean onPerformDefaultAction() {
		Toast.makeText(mContext, "Counter Menu Item selecter - "+"onPerformDefaultAction", 0).show();
		return true;
		};

		
}
